<?php

namespace app\api\controller;

use app\common\exception\BusinessException;
use think\response\Json;

class Profession extends Base
{
    /**
     * 查询列表
     * @return Json
     * @throws
     */
    public function getList(): Json
    {
        // 请求参数
        $param = $this->request->param();

        // 验证规则
        $rule = [
            'exam_id' => 'require',
            //'province_id' => 'require',
        ];

        // 错误信息
        $errMsg = [
            'exam_id.require' => '所属考试exam_id不得为空',
            //'province_id.require' => '所选省province_id不得为空',
        ];

        // 数据验证
        $valRel = $this->validate($param, $rule, $errMsg);
        if ($valRel !== true)
        {
            throw new BusinessException($valRel, 0);
        }

        // 查询数据
        $list = (new \app\api\logic\Profession())->getList($param);

        // 返回
        return $this->response($list);
    }
}